<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script type="text/javascript" src="../js/vue.js"></script>
</head>

<body>
    <div id="root">
        {{n}}
        <h2>当前的n值是:<span v-text="n"></span></h2>


        <button @click="add">点我n+1</button>
        <br />
        <button @click="bye">点我销毁vm</button>
    </div>


    <script type="text/javascript">
        const vm = new Vue({
            el: '#root',
            data: {
                n: 1
            },
            methods: {
                bye() {
                    this.$destroy();
                },
                add() {
                    console.log('add');
                    this.n += 1;
                }
            },
            mounted: function () {
                console.log('mounted');
            },
            beforeCreate: function () {
                console.log('beforeCreate');
                console.log(this);
            },
            created: function () {
                console.log('created');
            },
            beforeMount: function () {
                console.log('beforeMount');
            },
            mount: function () {
                console.log('mount');
            },
            destroy: function () {
                console.log('destroy');
            }

        })


    </script>
</body>

</html>